{template 'common/header-base'}
<style type="text/css">
    .we7-table td{
      text-align: center;
    }
</style>
<script type="text/javascript">
require(['jquery', 'district'], function ($, d) {
  $(function () {
    d.render({
      province: $('#p')[0],
      city: $('#c')[0],
      district: $('#d')[0]
    }, {
      province: "{$items['s_address'][0]}",
      city: "{$items['s_address'][1]}",
      district: "{$items['s_address'][2]}"
    }, {
      withTitle: true
    });
  });
});
</script>
{if $op == 'display'}
<div class="pull-right">
    <a href="{php echo $this->createWeburl('shangjia', array('op'=>'post'))}"  class="btn btn-primary we7-padding-horizontal" style="margin-bottom: 10px">添加商家</a>
</div>
<form class="form-horizontal" action="" method="post">
    <table class="table we7-table table-hover article-list vertical-middle">
        <tr>
            <td style="width:100px">排序</td>
            <td>商家名称</td>
            <td>商家logo</td>
            <td>商家负责人</td>
            <td>商家联系方式</td>
            <td>商家地址</td>
            <td>商家所属分类</td>
            <td>商家营业时间</td>
            <td>商家入驻结束时间</td>
            <td>商家收益</td>
            <td>商家是否审核</td>
            <td>操作</td>
        </tr>
        {loop $products $item}
        <tr>
            <td>
                {$item['s_id']}
            </td>
            <td>
                {$item['s_name']}
            </td>  
            <td>
                {if strpos($item['s_mendian'],"https")===false}
                <img src="{media $item['s_mendian']}" style="width: 100px;height: 100px;" alt="">
                {else}
                <img src="{$item['s_mendian']}" style="width: 100px;height: 100px;" alt="">
                {/if}
            </td>
            <td>
                {$item['s_u_name']}
            </td>
            <td>
                {$item['s_telphone']}
            </td>
            <td>
                {$item['s_address']}{$item['s_xxaddress']}
            </td>
            <td>
                {$item['s_type']}
            </td>
            <td>
                {$item['s_yingyetime']}
            </td>
            <td>
                {$item['ruzhu_endtime']}
            </td>
            <td>
                {$item['s_money']}
            </td>
            <td>
                {if $item['s_status']=="待审核"}<a class="btn btn-default btn-sm"  onclick="return confirm('确认通过审核？'); return false;" href="{php echo $this->createWeburl('shangjia', array('id' => $item['s_id'], 'op' => 'shen'))}">{$item['s_status']}</a>{/if}
                {if $item['s_status']=="审核通过"}<a class="btn btn-success btn-sm">{$item['s_status']}</a>{/if}
            </td>
            <td>
                <a class="btn btn-default btn-sm"  href="{php echo $this->createWeburl('shangjia', array('id' => $item['s_id'], 'op' => 'post'))}">编辑查看</a>
                <!-- <a class="btn btn-default btn-sm"  href="{php echo $this->createWeburl('shangjia', array('id' => $item['s_id'], 'op' => 'tixian'))}">提现详情</a> -->
                <!-- <a class="btn btn-default btn-sm"  href="{php echo $this->createWeburl('shangjia', array('id' => $item['s_id'], 'op' => 'posts'))}">商家详情</a> -->
                <a class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWeburl('shangjia', array('id' => $item['s_id'], 'op' => 'delete'))}">删除</a>
            </td>
        </tr>
        {/loop}
    </table>
</form>
{$pager}
{/if}
{if $op == 'post'}
<form class="form-horizontal" action="" method="post">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">添加商家</h3>
        </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">商家名称</label>
                <div class="form-controls col-sm-5">
                     <input type="text" name="s_name" id="s_name" value="{$items['s_name']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家名称</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家负责人</label>
                <div class="form-controls col-sm-5">
                     <input type="text" name="s_u_name" id="s_u_name" value="{$items['s_u_name']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家负责人</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">openid</label>
                <div class="form-controls col-sm-5">
                     <select name="s_u_openid" id="s_u_openid" class="form-control">
                        <option value="">--请选择--</option>
                        {loop $user $item}
                        <option value="{$item['openid']}" {if $items['s_u_openid']==$item["openid"]}selected{/if} >{$item['u_name']}</option>
                        {/loop}
                    </select>
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">openid必须为已存在的用户[不可不填]</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家联系方式</label>
                <div class="form-controls col-sm-5">
                     <input type="text" name="s_telphone" id="s_telphone" value="{$items['s_telphone']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家联系方式</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家logo</label>
                <div class="form-controls col-sm-5">
                    {php echo tpl_form_field_image('s_mendian', $items['s_mendian'])}
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家logo</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">商家分类</label>
                <div class="form-controls col-sm-5">
                    <select name="s_type" id="s_type" class="form-control">
                        <option value="">--请选择--</option>
                        {loop $type $item}
                        <option value="{$item['xt_name']}" {if $items['s_type']==$item["xt_name"]}selected{/if} >{$item['xt_name']}</option>
                        {/loop}
                    </select>
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家分类</div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="margin-right: 30px">商家地区</label>
                <div class="row">
                    <div class="col-sm-2">
                      <select id="p" class="form-control " name="province" value="{$items['s_address'][0]}">
                      </select>
                    </div>
                    <div class="col-sm-2">
                      <select id="c" class="form-control" name="city" value="{$items['s_address'][1]}">
                      </select>
                    </div>
                    <div class="col-sm-2">
                      <select id="d" class="form-control" name="district" value="{$items['s_address'][2]}">
                      </select>
                    </div>
                  </div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家地址</label>
                <div class="form-controls col-sm-5">
                    <input type="text" name="s_xxaddress" id="s_xxaddress" value="{$items['s_xxaddress']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家地址</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">地址经纬度 <span style="color: #c00">误填反</span></label>
                <div class="form-controls col-sm-2">
                    <input type="text" name="wei" id="wei" value="{$items['wei']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="form-controls col-sm-2 help-block" style="padding-left: 15px">纬度:30.88888</div>
                <div class="form-controls col-sm-2">
                    <input type="text" name="jing" id="jing" value="{$items['jing']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="form-controls col-sm-3 help-block" style="padding-left: 15px">经度:120.6666 <a href="http://lbs.qq.com/tool/getpoint/" target="_blank" style="color:#428BCA"> 经纬度查询</a></div>
            </div>
            
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家简介</label>
                <div class="form-controls col-sm-5">
                    <textarea rows="6" cols="20" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  name="s_content" id="s_content">{$items['s_content']}</textarea>                    
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家简介</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家营业时间</label>
                <div class="form-controls col-sm-5">
                    <input type="text" name="s_yingyetime" value="{$items['s_yingyetime']}"></textarea>                    
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家营业时间<p style="color: red;">00:00-24:00</p></div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家营业执照</label>
                <div class="form-controls col-sm-5">
                    {php echo tpl_form_field_image('s_zhizhao', $items['s_zhizhao'])}
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">营业执照</div>
            </div>
            <div class="form-group">
                <label for="" class="control-label col-sm-2" style="margin-right:45px">商家店铺幻灯片</label>
                <div class="form-controls col-sm-5">
                    {php echo tpl_form_field_multi_image('s_imgpath', $items['s_imgpath'])}
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">商家店铺幻灯片</div>
            </div>
            
    <div class="form-group">
        <div class="col-sm-12" style="margin-left: 200px;">
            <input name="token" type="hidden" value="{$_W['token']}" />
            <input type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交" />
        </div>
    </div>
</form>
{/if}
{if $op == 'posts'}
<form class="form-horizontal" action="" method="post">
    <table class="table we7-table table-hover article-list vertical-middle">
        <tr>
            <td style="width:100px">排序</td>
            <td>商家名称</td>
            <td>商家图标</td>
            <td>流水总额</td>
            <td>日流水总额</td>
            <td>月流水总额</td>
            <td>年流水总额</td>
            <td class="text-right">操作</td>
        </tr>
        {loop $productss $liushui}
        <tr>
            <td>
                {$liushui['l_id']}
            </td>
            <td>
                {$shangjia['s_name']}
            </td>
            <td>
                <img src="{media $shangjia['s_mendian']}" style="width: 100px;height: 100px;">
            </td> 
            <td>
                {$liushui['l_total']}
            </td> 
            <td>
                {$liushui['l_dtotal']}
            </td> 
            <td>
                {$liushui['l_mtotal']}
            </td> 
            <td>
                {$liushui['l_ytotal']}
            </td> 
            <td class="text-right">
                <a class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWeburl('shangjia', array('id' => $liushui['l_id'], 'op' => 'deletes'))}">删除</a>
            </td>
        </tr>
        {/loop}
    </table>
</form>
{/if}
{if $op == 'tixain'}
<form class="form-horizontal" action="" method="post">
    <table class="table we7-table table-hover article-list vertical-middle">
        <tr>
            <td style="width:100px">排序</td>
            <td>商户昵称</td>
            <td>商户logo</td>
            <td>提现订单号</td>
            <td>提现金额</td>
            <td>提现手续费</td>
            <td>提现时间</td>
            <td>提现状态</td>
            <td class="text-right">操作</td>
        </tr>
        {loop $products $item}
        <tr>
            <td>
                {$item['id']}
            </td>
            <td>
                {$item['user']['s_name']}
            </td>         
            <td>
                <img src="{$item['user']['s_mendian']}" style="width: 100px;height: 100px;" alt="">
            </td>
            <td>
                {$item['tnum']}
            </td>
            <td>
                {$item['money']}元
            </td>
            <td>
                {$item['s_money']}元
            </td>
            <td>
                {$item['time']}
            </td>
            <td>
                {if $item['statue']=="提现完成"} <a class="btn btn-info btn-sm">提现完成</a>{/if}
                {if $item['statue']=="待提现"} <a class="btn btn-default btn-sm">待提现</a>{/if}
            </td>
        </tr>
        {/loop}
    </table>
</form>
{/if}
{if $op == "yuangong"}
<form class="form-horizontal" action="" method="post">
    <table class="table we7-table table-hover article-list vertical-middle">
        <tr>
            <td style="width:100px">排序</td>
            <td>所属商家</td>
            <td>员工名称</td>
            <td>员工性别</td>
            <td>员工年龄</td>            
            <td>员工手机号</td>
            <td>服务状态</td>
            <td>是否禁止接单</td>
            <td>是否通过审核</td>
            <td>操作</td>
        </tr>
        {loop $products $item}
        <tr>
            <td>
                {$item['y_id']}
            </td>
            <td>
                {$item['s_name']}
            </td>
            <td>
                {$item['y_name']}
            </td>  
            <td>
                {$item['y_sex']}
            </td>
            <td>
                {$item['y_age']}
            </td>
            <td>
                {$item['y_telphone']}
            </td>
            <td>
                {$item['y_typs']}
            </td>
            <td>
                {if $item['y_jin']==0}否{else}是{/if}
            </td>
            <td>
                {if $item['y_styles']=="待审核"}<a class="btn btn-default btn-sm"  onclick="return confirm('确认通过审核？'); return false;" href="{php echo $this->createWeburl('shangjia', array('id' => $item['y_id'], 'op' => 'yuangongshen'))}">{$item['y_styles']}</a>{/if}
                {if $item['y_styles']=="审核通过"}<a class="btn btn-success btn-sm">{$item['y_styles']}</a>{/if}
            </td>
            <td>
                <a class="btn btn-default btn-sm"  href="{php echo $this->createWeburl('shangjia', array('id' => $item['y_id'], 'op' => 'yuangongpost'))}">查看详情</a>
                <a class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWeburl('shangjia', array('id' => $item['y_id'], 'op' => 'yuangongdelete'))}">删除</a>
            </td>
        </tr>
        {/loop}
    </table>
</form>
{$pager}
{/if}
{if $op == "yuangongpost"}
<form class="form-horizontal" action="" method="post">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">员工详情</h3>
        </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">员工名称</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['y_name']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">员工名称</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">员工性别</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['y_sex']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">员工性别</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">员工年龄</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['y_age']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">员工年龄</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">联系方式</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['y_telphone']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">联系方式</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">所属商家</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['s_name']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">所属商家</div>
            </div>    
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">身份证照片</label>
                <div class="form-controls col-sm-5">
                     <img src="{$items['y_imgpath1']}" style="width: 100px;">
                     <img src="{$items['y_imgpath2']}" style="width: 100px;">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">身份证照片</div>
            </div> 
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">技能</label>
                <div class="form-controls col-sm-5">
                    {loop $items['y_jineng'] $item}
                     <!-- <input type="text" value="{$item}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off"> -->
                     {$item}
                    {/loop}
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">技能</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">服务区域</label>
                <div class="form-controls col-sm-5">
                    {loop $items['y_fwqy'] $item}
                     <!-- <input type="text" value="{$item}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off"> -->
                     {$item}
                    {/loop}
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">服务区域</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">接单公里数</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['y_jdnum']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">接单公里数</div>
            </div> 
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">服务状态</label>
                <div class="form-controls col-sm-5">
                     <input type="text" value="{$items['y_typs']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">服务状态</div>
            </div>
            <div class="form-group" style="margin-top: 10px;">
                <label for="" class="control-label col-sm-2" style="margin-right:45px;">是否被禁止接单</label>
                <div class="form-controls col-sm-5">
                     {if $items['y_jin']==0}
                     <input type="text" value="否" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                     {else}
                    <input type="text" value="是" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" autocomplete="off">
                     {/if}
                </div>
                <div class="col-sm-1"></div>
                <div class="form-controls col-sm-3 help-block">是否被禁止接单</div>
            </div>
</form>
{/if}

